package com.niit.controller;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.niit.entity.Course;
import com.niit.entity.CourseDTO;
import com.niit.mapper.CourseMapper;

@Service
class ButterServiceImpl implements ButterService{
	Logger logger = LoggerFactory.getLogger("");
    @Resource
    private  CourseMapper courseMapper;
    @Transactional
	@Override
	public String rubickServe(String name) {
		// TODO Auto-generated method stub
		List<Course> result = courseMapper.findByMaxCount(20);
		logger.info(result.get(0).toString());
		courseMapper.insertOneCourse("数学", 45);
		return "stupid is "+ name;
	}
	@Override
	public List<CourseDTO> provideCourse(String studentName) {
		// TODO Auto-generated method stub
	/* if redis get*/
		return courseMapper.findCourseByStudentName(studentName);
	/*redis set*/
	}
	@Override
	public CourseDTO saveChoosenClass(String studentName, String course) {
		// TODO Auto-generated method stub
		Integer courseId = courseMapper.getCourseIdByString(course);
		//Integer studentName = course
		Integer studentId = courseMapper.getStudentIdByString(studentName);
	
		courseMapper.insertStucourse(courseId, studentId);
		return null;
	}
	
	

}
